class Solution {
public:
    int sumOfTheDigitsOfHarshadNumber(int x)
    {
        int ans = -1;
        int sum = 0;
        int t = x;
        while (x != 0)
        {
            sum += x % 10;
            x /= 10;
        }
        if (t % sum == 0) ans = sum;
        return ans;
    }
};